package com.we823.project.repository.service.we;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import com.we823.project.model.we.PermissionModel;
import com.we823.project.repository.dao.we.PermissionRepository;
import com.we823.project.repository.service.AbstractBaseService;

@Service("permissionService")
@Scope("prototype")
public class PermissionService extends AbstractBaseService<PermissionModel> {

	PermissionRepository permissionRepository;
	
	@Autowired
	public PermissionService(PermissionRepository permissionRepository) {
		super(permissionRepository);
		this.permissionRepository=permissionRepository;
	}

	public Map<Integer, PermissionModel> map() {
		Map<Integer, PermissionModel> map = new HashMap<Integer, PermissionModel>();
		List<PermissionModel> permissionModels = findAll();
		if(permissionModels!=null) {
			for (PermissionModel permissionModel : permissionModels) {
				map.put(permissionModel.getId(), permissionModel);
			}
		}
		return map;
	}

}
